<template>
	<view>
		
		<view v-if="deposit_pay_id" style="padding: 30rpx;display: flex;justify-content: center;">
			
			<u-image width="500rpx" height="500rpx" style="margin-top: 30rpx;" v-if="src" :src="src"></u-image>
		</view>
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				deposit_pay_id:null,
				src:null,
				depositPay:''
			}
		},
		onLoad(options) {
			var that=this;
			if (options.deposit_pay_id) {
				this.deposit_pay_id = options.deposit_pay_id;
				this.getVoucherCode(this.deposit_pay_id);
				
			}
		},
		mounted() {
			var that=this;
			// this.$ws.socketTask.onMessage(function(e){
			// 	console.log(e);
			// 	uni.$emit("getOrdersInfo", that.data);
			// 	that.$refs.uToast.show({
			// 		title: '授权成功',
			// 		type: 'success',
			// 		back:true
			// 	})
			// });
			setTimeout(function(){
				that.getInfo();
			},10000);
		},
		
		methods: {
			getInfo() {
				var that = this;
				that.$http.get('/depositPay/queryById?deposit_pay_id=' + this.deposit_pay_id, {}, (res) => {
					if (res.data.success) {
						that.depositPay = res.data.result;
						if(that.depositPay.deposit_state==2){
							that.$refs.uToast.show({
								title: '授权成功',
								type: 'success',
								back:true
							});
							uni.$emit("getOrdersInfo", that.data);
						}else{
							setTimeout(function(){
								that.getInfo();
							},10000);
						}
					} else {
						that.$refs.myModal.show('请求失败', res.data.result.message);
					}
				});
			},
			getVoucherCode(deposit_pay_id){
				var that=this;
				that.$http.get('/depositPay/getVoucherCode?deposit_pay_id=' + deposit_pay_id, {}, (res) => {
					if (res.data.success) {
						that.src = res.data.result;
						
					} else {
						that.refs.myModal.show('请求失败', res.data.result.message);
					}
				});
			},
		}
	}
</script>

<style>

</style>
